<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/3/3
  Time: 16:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>本届赛事</title>
    <!--框架必需start-->
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/language/cn.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/framework.js"></script>
    <link href="${pageContext.request.contextPath}/static/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" id="skin" prePath="${pageContext.request.contextPath}/static/qui/" />
    <link rel="stylesheet" type="text/css" id="customSkin" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/popup/toast.js"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/table/quiGrid.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/form/form.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/form/validationRule.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/form/validation.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/form/datePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>


</head>
<body>
<form id="inputFrom" action="/thisRace/addThisRace" method="post"  showOnMouseOver="false">
    <div class="page_content">
        <table class="formStyle">
            <input type="hidden" name="id" value="" />
            <input type="hidden" id="deleteFile" name="deleteFile" value="0" />
                <tr>
                    <td width="110" class="ali03">年份：</td>
                    <td width="200">
                        <input type="text"    class="date"  dateFmt="yyyy" id="year" name="year" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">赛事标题：</td>
                    <td width="200">
                        <input type="text"  id="title" name="title" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">赛事内容：</td>
                    <td width="200">
                        <textarea style="width: 300px" id="raceContent" name="raceContent" class="validate[required]"></textarea>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">开始时间：</td>
                    <td width="200">
                        <input type="text"  class="date"  id="beginTime" name="beginTime" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">结束时间：</td>
                    <td width="200">
                        <input type="text"   class="date" id="endTime" name="endTime" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">附件：</td>
                    <td width="200">
                        <input type="file"  accept="application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" id="file" name="file"  />
                        <div id="fileList" style="display: none">
                            <a href="javascript:void(0)">下载</a>
                            <a href="javascript:void(0)" onclick="deleteFile()">删除</a>
                        </div>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
        </table>
    </div>
</form>
<script>
    function deleteFile() {
        $("#deleteFile").val("1");
        $("#fileList").hide();
    }
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return decodeURI(r[2]);
        return "";
    }
    var flag=getQueryString("flag");
    var id=getQueryString("id");
    if(flag==="edit"){
        $("#inputFrom").attr("action","/thisRace/editThisRace");
        $.getJSON("/thisRace/getThisRaceById",{"id":id},
            function(result){
                $('#inputFrom').ajaxWrite({data:result.data});
                if(result.data.filePath!=null){
                    $("#fileList").show();
                    $("#fileList a:eq(0)").attr("href","/upload"+result.data.filePath);
                }
            },"json");
    }
    function submitHandler(){
        var valid = $('#inputFrom').validationEngine({returnIsValid: true, showOnMouseOver:false});
        if(valid){
            $('#inputFrom').ajaxSubmit({
                //表单提交成功后的回调
                success: function(data, statusText, xhr, $form){
                    if(data.success){
                        top.Toast('showSuccessToast', data.msg);
                        //刷新数据
                        top.frmright.refresh();
                        //关闭窗口
                        top.Dialog.close();
                    }
                    else{
                        top.Toast('showWarningToast', data.msg);
                    }
                }
            });
        }
        return false;
    }
</script>
</body>
</html>
